<?php
require_once '../../Lib/main.php';
try {
	$page = 0;
	$start = 0;
	$limit = 25;
	if (isset($_REQUEST['page'])) {
		$page = $_REQUEST['page'];
	}
	
	if (isset($_REQUEST['start'])) {
		$start = $_REQUEST['start'];
	}
	
	if (isset($_REQUEST['limit'])) {
		$limit = $_REQUEST['limit'];
	}
	
	$productDAO = new Dao_ProductDAO();
	$listProductClass = $productDAO->getProductWithoutDelete($start, $limit);
	
	$cnt = $productDAO->countProductWithoutDelete();
	$arr = array();
	/* @var $product Model_Product */
	foreach ($listProductClass as $key => $product) {
		$inArr = array();
		$inArr['id'] = $product->getId();
		$inArr['name'] = $product->getName();
		$inArr['product_class'] = $product->getNameClass();
		$inArr['category_name'] = $product->getNameCategory();
		$inArr['price'] = $product->getPrice();
		$inArr['delStatus'] = $product->getDeleteFlgByString();
		$arr[] = $inArr;
	}
	
	echo json_encode(array('success' => true, 'items' => $arr, 'total' => $cnt));
	
} catch (Exception $e) {
	echo json_encode(array('success' => false,'error' => $e->getMessage()));
}


